<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>

<head>
    <title>部门管理列表</title>
</head>

<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row m-t-sm">
            <div class="col-lg-12">
                <ol class="breadcrumb f-fl">
                    <li>
                        <i class="fa fa-location-arrow"></i>  <a>部门管理列表</a>
                    </li>
                    <li class="active">
                        <strong>部门管理列表</strong>
                    </li>
                </ol>
                <span class="navbar-right  m-r m-t-8"><a href="${ctx}/admin/ehm/dept/add" class="btn-primary btn-add "> <i class='fa fa-plus-square-o'></i> 新 增</a></span>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox">
                        <div class="ibox-content">
                            <div class="search-area">
                                <form role="form" class="form-inline" id="queryform">
                                    <label for="title">
                                        <select name="status"  class="form-control form-filter" form="queryform" style="width:100%">
                                            <option value="">请选择状态</option>
                                            <option value="10" selected="true">启用</option>
                                            <option value="20">停用</option>
                                        </select></label>
                                    <label for="title">
                                        <input type="input" placeholder="部门名称" name="title"
                                               id="title"
                                               class="form-control form-filter"></label>
                                    <button class="btn btn-primary" type="button" onclick="submitFilter()"> 查询</button>
                                    <button class="btn btn-primary" datatable-clear type="button"> 清除</button>
                                </form>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover dataTables" id="data-table"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>


<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {
        var setting = {
            "ajax": {
                "url": "${ctx}/admin/ehm/dept/list",
                "type": "POST"
            },
            "columns": [
                {"title": "部门编号", "data": "sn", "width": "25%", "orderable": true},
                {"title": "部门名称", "data": "title", "width": "25%", "orderable": true},
                {"title": "部门人数", "data": "deptNum", "width": "25%", "orderable": true},
                {"title": "操作", "data": null, "width": "25%", "orderable": false}
            ],
            "columnDefs": [
                {
                    "targets": 3,
                    "render": function (data, type, row, meta) {
                        if(data.status!=null && data.status!=undefined && data.status == 10){
                            if(data.deptNum == 0){
                                return "<a class='btn btn-xs default btn-editable' href='${ctx}/admin/ehm/dept/edit?id=" + data.id + "'><i class='fa fa-pencil-square-o'></i> 编辑 </a>" +
                                        "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/ehm/dept/open' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-minus-square-o'></i> 停用 </a>";
                            }else{
                                return "<a class='btn btn-xs default btn-editable' href='${ctx}/admin/ehm/dept/edit?id=" + data.id + "'><i class='fa fa-pencil-square-o'></i> 编辑 </a>";
                            }
                        }else{
                            return "<a class='btn btn-xs default btn-editable' href='${ctx}/admin/ehm/dept/edit?id=" + data.id + "'><i class='fa fa-pencil-square-o'></i> 编辑 </a>" +
                                    "<a class='btn btn-xs default btn-editable' data-opt data-opt-url='${ctx}/admin/ehm/dept/open' data-opt-pams='{\"id\":" + data.id + "}' data-opt-fun='$(\"#data-table\").DataTable().draw();'  ><i class='fa fa-minus-square-o'></i> 启动 </a>";
                        }
                    },
                    "orderable": false
                }
            ],
            "order": [
                [0, "desc"]
            ],
        };
        /* Init DataTables */
        $('#data-table').DataTable(ehconfig.get_datatable_config(setting));
        submitFilter = function () {
            $('#data-table').DataTable().draw();
        }
    });
</script>

</body>

</html>
